import axios from 'axios';
import _ from 'lodash';
let LocationHostName = window.location.hostname;
if (LocationHostName === 'localhost' || LocationHostName === '127.0.0.1') {
    LocationHostName = '/';
}else{
    LocationHostName=window.location.origin+'/index.php?s='
}
let API = {
    ASSET_SERVER_URL:LocationHostName,
    LOGIN_IMG: '/api/common/index/uploadImg', //图片上传 
    LOGIN_VIDEO: '/api/common/index/uploadVideoFile', //视频上传 
    GET_WX_CODE:'/api/wechat/Yfwxapi/getWxCode',//获取公众号code
    GET_WX_USERINFO:'/api/wechat/Yfwxapi/getUserInfo',//公众号授权
    GET_APP_USERINFO:'/api/wechat/Yfmember/getUserInfo',//获取用户信息
    GET_SETUSERROLE:'/api/wechat/Yfmember/setUserRole',//获取用户信息
    GET_ACTIVE_LIST:'/api/wechat/Yfhome/activeList',//获取赛事列表
    GET_ACTIVE_DETAIL:'/api/wechat/Yfhome/activeDetail',//获取赛事详情
    SET_USERINFO:'/api/wechat/Yfhome/setUserInfos',//更新用户信息
    USER_SIGNUP:'/api/wechat/Yfhome/setUserSingUp',//用户报名
    USER_WORKS_LIST:'/api/wechat/Yfhome/userWorksList',//作品列表
    USER_WORKS_DEL:'/api/wechat/Yfhome/userWorksDel',//作品列表删除
    UPLOAD_USER_WORKS:'/api/wechat/Yfhome/submitUserUpload',//作品图片上传
    UPLOAD_USER_VIDEO_WORKS:'/api/wechat/Yfhome/submitUserVideoUpload',//作品图片上传
    UPLOAD_USER_IMGS:'/api/wechat/Yfhome/uploadImg',//身份信息删除
    SUBMIT_USER_WORKS:'/api/wechat/Yfhome/submitUserWorks',//作品提交
    USER_SINGUP_LIST:'/api/wechat/Yfhome/userSingupList',//报名列表
    USER_RANK_LIST:'/api/wechat/Yfhome/userRankList',//排行版
    SCORING_LIST:'/api/wechat/Yfhome/scoringList',//评委评审列表
    SET_SCORING:'/api/wechat/Yfhome/scoring',//评委打分
    USER_SIGNUP_DEL:'/api/wechat/Yfhome/delSingUp',//删除打分
    IS_PLY_WROKS:'/api/wechat/Yfhome/isPayWorks',//是否已打分
    GET_SIGN_PACKAGE:'/api/wechat/Yfwxapi/getSignPackage',//公众号网页授权登录
    WX_NEWPAY:'/api/wechat/Yfwxapi/newpay',//微信支付
    USER_CERTIFICATE_LIST:'/api/wechat/Yfhome/certificate',//证书列表
    USER_RANK_CERTIFICATE:'/api/wechat/Yfhome/certificateDown',//证书下载
    RECOGNITION_LIST:'/api/wechat/Yfmember/listRecognition',//身份信息列表
    RECOGNITION_DEL:'/api/wechat/Yfmember/delRecognition',//身份信息删除
    RECOGNITION_EDIT:'/api/wechat/Yfmember/setRecognition',//身份信息删除
    RECOGNITION_DETAIL:'/api/wechat/Yfmember/detailRecognition',//身份信息删除
};

export function getConfig(){
    return new Promise(resolve=>{
        axios.get(`${window.location.origin}/${(process.env.NODE_ENV === 'development'?'':'weChatApp')}/webconfig.json?v=${new Date().getTime()}`).then((response) => {
            if (response.data && _.isPlainObject(response.data)) {
                resolve(Object.assign(API, response.data))
            }else{
                resolve(API)
            }
        }, () => {
            resolve(API)
        });
    })
}
export default API;


